# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

#Set flags to detect arm32 bit or arm64 bit for switching between elf structures
if(${ANDROID_ABI} STREQUAL "armeabi-v7a" OR ${ANDROID_ABI} STREQUAL "x86")
    add_definitions("-D_32_BIT")
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a" OR ${ANDROID_ABI} STREQUAL "x86_64")
    add_definitions("-D_64_BIT")
endif()

#将源码添加到NATIVE_SRC
aux_source_directory(. NATIVE_SRC)

add_library(
        # Sets the name of the library.
        safeKeyboard
        # Sets the library as a shared library.
        SHARED
        # Provides a relative path to your source file(s).
        safeKeyboardLib.cpp
        aes.cpp
        native-lib.c
        stringUtil.cpp
)

target_include_directories(safeKeyboard PRIVATE arch/${ANDROID_ABI})

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

find_library( # Sets the name of the path variable.
        log-lib
        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

target_link_libraries(
        # Specifies the target library.
        safeKeyboard
        ${log-lib})
